package com.spring.sunflower.conversation

import androidx.constraintlayout.widget.ConstraintLayout
import com.bumptech.glide.Glide
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.spring.sunflower.R
import com.spring.sunflower.bean.ChatGiftBean

/**
 * Created by Kevin on 2021/7/31<br/>
 *
 * Describe:<br/>
 */
class GiftAdapter(layoutResId: Int, data: MutableList<ChatGiftBean.Data>) :
    BaseQuickAdapter<ChatGiftBean.Data, BaseViewHolder>(layoutResId, data) {
    override fun convert(holder: BaseViewHolder, item: ChatGiftBean.Data) {
        Glide.with(context)
            .load(item.imagePath)
            .placeholder(R.drawable.ic_placeholder)
            .into(holder.getView(R.id.ivGift))
        holder.setText(R.id.tvGiftName, item.name)
        holder.setText(R.id.tvPrice, "${item.price}金币")
        val clContainer = holder.getView<ConstraintLayout>(R.id.clContainer)
        if (item.checked) {
            clContainer.background = context.getDrawable(R.drawable.ic_bg_stroke_yellow_with_solid)
        } else {
            clContainer.background = context.getDrawable(R.drawable.bg_shape_transparent)

        }
    }
}